//3069.将元素分配到两个数组中I
//https://leetcode.cn/problems/distribute-elements-into-two-arrays-i/
class Solution {
public:
    vector<int> resultArray(vector<int>& nums) {
        int n = nums.size();
        if(n<=1) return nums;

        vector<int> arr1{nums[0]},arr2{nums[1]};

        for(int i = 2;i<n;++i)
        {
            if(arr1.back() > arr2.back()) arr1.emplace_back(nums[i]);
            else arr2.emplace_back(nums[i]);
        }
        arr1.reserve(nums.size());
        for(int num:arr2) arr1.emplace_back(num);
        return arr1;
    }
};